package com.yand.thread.rabbitRun2;

public class Tortoise extends Thread{

    private int speed = 1;

    private int  sum = 0;

    private Callback callback;
    private int length = 100;

    public void setCallback(Callback callback) {
        this.callback = callback;
    }

    public void run(){


        while((length-sum) > 0){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            sum += speed;
            System.out.println("乌龟一共跑了"+sum+"米");
            System.out.println("距离终点还剩下"+(length-sum)+"米");
        }
        System.out.println("乌龟赢了，小兔子别跑了");
        //跑完了乌龟赢了， 通知兔子不用跑了
        callback.stopRabbit();
    }

}
